MODULE_NAME := libdrivers.a

TOP_DIR := ../
TARGET := $(TOP_DIR)$(LIB_DIR)/$(MODULE_NAME)
CUR_DIR	 := $(shell pwd)
CUR_DIR_NAME := $(notdir $(CUR_DIR))
MOD_BUILD_DIR := $(TOP_DIR)$(BUILD_DIR)/$(CUR_DIR_NAME)

SRCS := $(wildcard src/*.c )
OBJS := $(SRCS:%.c=$(MOD_BUILD_DIR)/%.o)

.PHONY: all clean distclean
all: $(TARGET) 

$(MOD_BUILD_DIR)/%.o:%.c
	$(Q) mkdir -p $(dir $@)
	$(Q) $(CC) $(CFLAGS) -c $< -o $@
	
$(TARGET): $(OBJS)  
	$(Q) $(AR) -rcs $@ $^ 
	$(Q) $(RANLIB) $@
#	$(Q) $(STRIP) $@
	
clean:
	$(Q) rm -rf $(TARGET)	
	$(Q) rm -rf $(OBJS)
	$(Q) touch Makefile

distclean:
	$(Q) rm -rf $(MOD_BUILD_DIR)
	$(Q) rm -rf $(TARGET)	
	$(Q) rm -rf $(OBJS)
	$(Q) touch Makefile
	
